﻿using System;
using System.Drawing;

using Microsoft.WowAddonStudio.FrameXml.Serialization;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Support
{
    public static class PointExtensions
    {
        /// <summary>
        /// Offsets the point by the given offset dimension.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <param name="offset">The offset.</param>
        /// <returns>A <see cref="Point"/> structure.</returns>
        public static Point Offset(this Point point, Dimension offset)
        {
            if (offset == null)
                throw new ArgumentNullException("offset");

            // Implicitly convert to point
            var offsetPoint = offset.IsAbsolute ? offset.ToPoint() : new Point();

            // Offset the original point
            point.Offset(offsetPoint.X, offsetPoint.Y);

            // Return the point
            return point;
        }
    }
}
